package com.lkx.web;

import com.lkx.service.UserDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

/**
 * ClassName: UserController
 * Function:  TODO
 * Date:      2018-12-17 12:41
 * author     黄曦
 * version    V1.0
 */
@Controller
public class IndexController {
    @Autowired
    private UserDataService userDataService;

    @RequestMapping("/")
    public ModelAndView list(HttpSession session,String userGroup,String keyword) {
        ModelAndView view = new ModelAndView("userData/list");
        Map<String,Object> map = new HashMap<>();
        if(("1").equals(userGroup)){
            map.put("dataName",keyword);
        }else{
            map.put("userGroup",keyword);
        }
        view.addObject("userlist",userDataService.list(map));
        if(session.getAttribute("username") != null){
            view.addObject("username",session.getAttribute("username"));
        }
        return view;
    }


}
